package com.example.springbott.controller;

import com.example.springbott.aspactJ.OperationName;
import com.example.springbott.bean.BaseRespVo;
import com.example.springbott.bean.MarketAdmin;
import com.example.springbott.bean.common.BasePageInfo;
import com.example.springbott.bean.common.CommonData;
import com.example.springbott.service.AdminAdminService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author: 小朱
 * @Description:
 * @date: 21:22 2022/11/20
 */
@RestController
@RequestMapping("admin/admin")
public class AdminAdminController {
    @Autowired
    AdminAdminService adminAdminService;
//------------------------------小朱-----------------------------------
    @RequiresPermissions("admin:admin:list")
    @RequestMapping("list")
    @OperationName("1")
    public BaseRespVo adminAdminList(BasePageInfo basePageInfo, String username) {
        CommonData commonData = adminAdminService.adminAdminList(basePageInfo, username);

        return BaseRespVo.ok(commonData);
    }

    @RequiresPermissions("admin:admin:create")
    @RequestMapping("create")
    @OperationName("5")
    public BaseRespVo adminAdminCreate(@RequestBody MarketAdmin marketAdmin, MultipartFile file) throws IOException {
        MarketAdmin marketAdmin1 = adminAdminService.adminAdminCreate(marketAdmin, file);
        //响应的语句
        return BaseRespVo.ok(marketAdmin1);
    }

    @RequiresPermissions("admin:admin:update")
    @RequestMapping("update")
    @OperationName("5")
    public BaseRespVo adminAdminUpdate(@RequestBody MarketAdmin marketAdmin) {
        MarketAdmin marketAdmin1 = adminAdminService.adminAdminUpdate(marketAdmin);
        return BaseRespVo.ok(marketAdmin1);
    }

    @RequiresPermissions("admin:admin:delete")
    @RequestMapping("delete")
    @OperationName("1")
    public BaseRespVo adminAdminDelete(@RequestBody MarketAdmin marketAdmin) {
        adminAdminService.adminAdminDelete(marketAdmin);
        return BaseRespVo.ok();
    }
}

